//
// Copyright 2011-2015 Jeff Bush
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

#include "asm_macros.h"

// This test patches a nop instruction in the middle of a loop to convert it
// to a jump out of the loop
// This test should fail if the iinvalidate is commented out.

            .globl _start

_start:     lea s0, jumploc
            li s1, 0xf6000006    // b +24

looptop:    move s10, 1
jumploc:    nop                // This location will be patched
1:          move s10, 2

            // patch instruction to jump out of loop
            store_32 s1, (s0)
            iinvalidate s0
            membar
            b looptop

            // Control will flow here after patch
breakout:   move s10, 3

            call pass_test
